<?php
/**
 * Created by PhpStorm.
 * User: zhanghua
 * Date: 2018/9/21
 * Time: 18:24
 */

namespace app\sun\service;


use app\common\service\ModelBaseService;
use app\sun\model\AdminPerm;
use app\sun\model\AdminRolePermRelation;

class AdminPermService extends ModelBaseService
{
    protected $modelName = 'app\\sun\\model\\AdminPerm';

    /**
     * 根据角色获取菜单
     * @param $role_id
     * @return false|static[]
     */
    protected function getAdminMenuByRole($roleId)
    {


    }

    /**
     * 获取所有一级的菜单
     * @return false|static[]
     */
    protected function getTopMenu()
    {
        return AdminPerm::Where('is_menu', 1)->where('menu_pid', 0)->all();
    }

    /**
     * 获取所有的菜单
     */
    protected function getAllMenu()
    {
        return AdminPerm::Where('is_menu', 1)->all();
    }

    /**
     * @param $menuId
     * @return bool
     */
    protected function delMenu($menuId)
    {
        return $result = AdminPerm::destroy($menuId);
    }


}